import {Home} from 'home-model';
var home = new Home;//引用其他的js文件，必须是这样的写法
Page({

    /**
     * 页面的初始数据
     */
    data: {
        loadingHidden:false,
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        this._loadData();
    },
    _loadData:function (callback) {
        var that = this;
        home.getBannerDate(res => {
            that.setData({
                bannerArray:res,
            });
        })
        home.getThemeData(res=>{
            that.setData({
                themeS:res,
                loadingHidden:true
            });
        })
        home.getProductorData(res=>{
            that.setData({
                productArr:res
            })
            callback && callback();
        })
    },
    onThemesItemTap:function (event) {
        var id = home.getDataSet(event,'id');
        var name = home.getDataSet(event,'name');
        wx.navigateTo({
          url: '../theme/theme?id=' + id + '&name=' + name,
          success: function(res) {},
          fail: function(res) {},
          complete: function(res) {},
        })
    },
    onProductsItemTap:function (event) {
        var id = home.getDataSet(event,'id');
        wx.navigateTo({
          url: '../product/product?id=' + id,
          success: function(res) {},
          fail: function(res) {},
          complete: function(res) {},
        })
    },
})